package cz.data.common.support.metadata;

import cz.data.common.support.DataTypeEnum;

public enum EsDataTypeEnum implements DataTypeEnum {

    KEYWORD("keyword", "字符关键字"),
    TEXT("text", "字符长文本"),
    BYTE("byte", "byte数字"),
    SHORT("short", "短数字"),
    INTEGER("integer", "数字"),
    LONG("long", "长数字"),
    FLOAT("float", "单精度小数"),
    DOUBLE("double", "双精度小数"),
    DATE("date", "日期时间"),
    BOOLEAN("boolean", "布尔"),
    BINARY("binary", "二进制"),
    FLATTENED("flattened", "扁平化JSON")
    ;

    private final String value;
    private final String title;

    EsDataTypeEnum(String value, String title) {
        this.value = value;
        this.title = title;
    }

    public String getValue() {
        return value;
    }

    @Override
    public String getTitle() {
        return title;
    }

    public static EsDataTypeEnum match(String value, EsDataTypeEnum defaultItem) {
        if (value != null) {
            for (EsDataTypeEnum item: EsDataTypeEnum.values()) {
                if (item.getValue().equalsIgnoreCase(value)) {
                    return item;
                }
            }
        }
        return defaultItem;
    }
}
